#ifndef PAYOFFFACTORY_H
#define PAYOFFFACTORY_H

#include <string>
#include <map>
#include <vector>
#include "PayOff.h"
//abstract factory pattern, implemented by singleton pattern
class PayOffFactory
{
public:
	typedef PayOff* (*CreatePayOff)(double); //this function must be static
	static PayOffFactory& Instance(); //singleton
public:
	void registerPayOff(std::string payoff_id, CreatePayOff payoff_creator);
	PayOff* createPayOff(std::string payoff_id, double strike); //abstract factory
	std::vector<std::string> getAllPayOffs() const;

private:
	std::map<std::string, CreatePayOff> m_payoffs;
private: //pricate constructor, copy constructor, and assignment operator
	PayOffFactory(){};
	PayOffFactory(const PayOffFactory&){}
	PayOffFactory& operator=(const PayOffFactory&){return *this;}
};

#endif